package invalidosgibusinessservicedependency;

import org.eclipse.emf.ecore.EObject;

import org.eclipse.viatra2.emf.incquery.validation.runtime.Constraint;
import org.eclipse.viatra2.emf.incquery.validation.runtime.ValidationUtil;
import org.eclipse.viatra2.emf.incquery.runtime.api.impl.BaseGeneratedMatcherFactory;
import invalidosgibusinessservicedependency.InvalidOSGiBusinessServiceDependencyMatch;
import invalidosgibusinessservicedependency.InvalidOSGiBusinessServiceDependencyMatcherFactory;
import invalidosgibusinessservicedependency.InvalidOSGiBusinessServiceDependencyMatcher;

public class InvalidOSGiBusinessServiceDependencyConstraint extends Constraint<InvalidOSGiBusinessServiceDependencyMatch> {

	private InvalidOSGiBusinessServiceDependencyMatcherFactory matcherFactory;

	public InvalidOSGiBusinessServiceDependencyConstraint() {
		matcherFactory = new InvalidOSGiBusinessServiceDependencyMatcherFactory();
	}

	@Override
	public String getMessage() {
		return "$osgiService.name$ OSGi business service should not depend from $otherService.name$ business service, cause it is implemented with another technology!";
	}

	@Override
	public EObject getLocationObject(InvalidOSGiBusinessServiceDependencyMatch signature) {
		Object location = signature.get("osgiService");
		if(location instanceof EObject){
			return (EObject) location;
		}
		return null;
	}
	
	@Override
	public int getSeverity() {
		return ValidationUtil.getSeverity("error");
	}
	
	@Override
	public BaseGeneratedMatcherFactory<InvalidOSGiBusinessServiceDependencyMatch, InvalidOSGiBusinessServiceDependencyMatcher> getMatcherFactory() {
		return matcherFactory;
	}
}
